MICS Globe Test

Andy Grogan-Kaylor https://www.umich.edu/~agrogan (University of Michigan)https://www.umich.edu
2022-02-23

Libraries

Show code

Data

Show code
country <- c("Algeria",  "Argentina",  "Bangladesh",  "Barbados",  "Belarus",  
             "Belize",  "Benin",  "Bosnia and Herzegovina",  "Cameroon",  
             "Central African Republic",  
             "Chad",  "Democratic Republic of the Congo",  "Republic of the Congo",
             "Costa Rica",  "Cote d'Ivoire",  
             "Dominican Republic",  "El Salvador",  "Eswatini",  "Ghana",  "Guinea", 
             "Guinea Bissau",  "Guyana",  "Iraq",  "Jamaica",  "Kazakhstan",  
             "Kenya",  "Kosovo",  "Kyrgyzstan",  "Laos", "Macedonia",  
             "Madagascar",  "Malawi",  "Mali",  "Mauritania",  "Mexico",  
             "Moldova",  "Mongolia",  "Montenegro",  "Nepal",  "Nigeria",  
             "Pakistan",  "Panama",  "Paraguay",  "Sao Tome and Principe",  "Senegal",
             "Serbia",  "Sierra Leone",  "Somalia",  "St. Lucia",  "State of Palestine",
             "Suriname",  "Thailand",  "The Gambia",  "Togo",  "Trinidad and Tobago", 
             "Tunisia",  "Turkmenistan",  "Ukraine",  "Uruguay",  "Vietnam",  
             "Zimbabwe")

MICScountries <- data.frame(country)

MICScountries$country_iso <- countrycode(MICScountries$country, 
                                 'country.name', 
                                 'iso3c')

Configuration

Show code
# geographic options

g <- list(showframe = TRUE, 
          showcoastlines = TRUE, 
          showcountries = TRUE,
          showland = TRUE,
          countrycolor = toRGB("grey"),
          showocean = TRUE,
          # projection = list(type = 'robinson'),
          projection = list(type = 'orthographic',
                            rotation = list(lon = 0,
                                            lat = 0,
                                            roll = 0)),
          showland = TRUE,
          landcolor = toRGB("grey"))

g2 <- list(showland = TRUE,  
           landcolor = toRGB("grey"),
           showcountries = TRUE,
           showocean = FALSE, 
           projection = list(type = 'orthographic',
                             rotation = list(lon = 0,
                                             lat = 0,
                                             roll = 0)),
           lataxis = list(showgrid = TRUE,
                          gridcolor = toRGB("black")),
           lonaxis = list(showgrid = TRUE,
                          gridcolor = toRGB("black")))

g3 <- list(showland = TRUE,  
           landcolor = toRGB("grey"),
           showcountries = TRUE,
           showocean = FALSE, 
           projection = list(type = 'robinson'),
           lataxis = list(showgrid = TRUE,
                          gridcolor = toRGB("black")),
           lonaxis = list(showgrid = TRUE,
                          gridcolor = toRGB("black")))

g4 <- list(showland = TRUE,  
           landcolor = toRGB("grey"),
           showcountries = TRUE,
           showocean = TRUE, 
           oceancolor = toRGB("white"),
           projection = list(type = 'orthographic',
                             rotation = list(lon = 0,
                                             lat = 0,
                                             roll = 0)),
           lataxis = list(showgrid = TRUE,
                          gridcolor = toRGB("lightblue")),
           lonaxis = list(showgrid = TRUE,
                          gridcolor = toRGB("lightblue")))


# text options

t <- list(
  family = "sans serif",
  size = 8,
  color = toRGB("black"))

# line options

l <- list(color = toRGB("grey"), width = 0.5)

Globes

NB that the globes allow you to take a snapshot of a particular view with the icon.

One

Show code
MICScountries %>% 
  plot_geo() %>% 
  add_trace(text = ~country, 
            # z = 1,
            hoverinfo = 'text',
            locations = ~country_iso, 
            marker = list(size = 10, color = "red")) %>%
  layout(geo = g)

Two

Show code
MICScountries %>% 
  plot_geo() %>%   
  add_trace(locations = ~country_iso,
            color = 1,
            z = 1, 
            text = ~country, 
            hoverinfo = 'text',
            colors = colorRamp(c("gold", "gold")),
            marker = list(line = l),
            showscale = FALSE) %>%
  layout(geo = g2)

Three (Not really a globe, but shows the whole earth at one time)

Show code
MICScountries %>% 
  plot_geo() %>%   
  add_trace(locations = ~country_iso,
            color = 1,
            z = 1, 
            text = ~country, 
            hoverinfo = 'text',
            colors = colorRamp(c("gold", "gold")),
            marker = list(line = l),
            showscale = FALSE) %>%
  layout(geo = g3)

Four

Show code
MICScountries %>% 
  plot_geo() %>%   
  add_trace(locations = ~country_iso,
            color = 1,
            z = 1, 
            text = ~country, 
            hoverinfo = 'text',
            colors = colorRamp(c("#009EDB", "#009EDB")),
            marker = list(line = l),
            showscale = FALSE) %>%
  layout(geo = g4)